不是PE文件, 进IDA
分析, F5看伪代码.
main()
里面有个patch_me()
,
在patch_me()
里面找到get_flag()
关键函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| unsigned __int64 get_flag() { unsigned int v0; int i; int j; __int64 s; char v5; unsigned __int64 v6;
v6 = __readfsqword(0x28u); v0 = time(0LL); srand(v0); for ( i = 0; i <= 4; ++i ) { switch ( rand() % 200 ) { case 1: puts("OK, it's flag:"); memset(&s, 0, 0x28uLL); strcat((char *)&s, f1); strcat((char *)&s, &f2); printf("%s", (const char *)&s); break; case 2: printf("Solar not like you"); break; case 3: printf("Solar want a girlfriend"); break; case 4: s = 0x7F666F6067756369LL; v5 = 0; strcat(&f2, (const char *)&s); break; case 5: for ( j = 0; j <= 7; ++j ) { if ( j % 2 == 1 ) *(&f2 + j) -= 2; else --*(&f2 + j); } break; default: puts("emmm,you can't find flag 23333"); break; } } return __readfsqword(0x28u) ^ v6; }
|
关键就在1,4,5
这三个case
里,
应该要以合适的顺序执行才能得到flag
分析出来正确的顺序应该是4,5,1
, 写成Python代码如下
1 2 3 4 5 6 7 8 9
| string0 = "GXY{do_not_" string1 = "\x69\x63\x75\x67\x60\x6f\x66\x7f" for i in range(0,len(string1)): if i % 2 == 1: string0 += chr(ord(string1[i]) - 2) else: string0 += chr(ord(string1[i]) - 1) print(string0)
|
所以flag就是GXY{do_not_hate_me}